<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class StockTransfer extends Model
{
	use SoftDelete;
	
    // 表名
    protected $name = 'stock_transfer';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';
	
	public function fromuser()
    {
        return $this->belongsTo('User', 'from_uid', 'id', [], 'LEFT')->setEagerlyType(0);
    }
	
    public function touser()
    {
        return $this->belongsTo('User', 'to_uid', 'id', [], 'LEFT')->setEagerlyType(0);
    }
	
	public function stock()
    {
        return $this->belongsTo('Stock', 'sid', 'id', [], 'LEFT')->setEagerlyType(0);
    }
	
	public function fromdepart()
    {
        return $this->hasOne('UserDepart', 'id', 'from_depart', [], 'LEFT')->setEagerlyType(0);
    }
	
	public function todepart()
    {
        return $this->hasOne('UserDepart', 'id', 'to_depart', [], 'LEFT')->setEagerlyType(0);
    }
}
